<template>
<a-card :bordered="false">
    <div class="table-operator">
        <a-button shape="round" size="small" type="primary" icon="plus"  @click="handleEdit({dictType:'3',systemNo:systemNo},'cacheDictForm','新增')">新建</a-button>
        
    </div>
    <LTable
        ref="cacheDictList"
        size="middle"
        rowKey="keyId"
        :formAttributes="formAttributes"
        :columns="columns"
        :queryForm="queryForm"
        :initQuery="initQuery"
        :initOrder="initOrder"
        :axiosUrl="axiosUrl"
        :showPagination="true"
        :showQueryForm="true"
        :isAutoLoad="false"
      >

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'cacheDictForm',record.dictName)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete({keyId:record.keyId,dictCode:record.dictCode},'/SysDictController/del','cacheDictList')">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </LTable>
        <cacheDictForm ref="cacheDictForm" @close="refresh('cacheDictList')" @ok="refresh('cacheDictList')"></cacheDictForm>
</a-card>
    
</template>

<script>
import LTable from '@/components/lt/LTable'
import {SysMixin} from '@/mixins/SysMixin'
import cacheDictForm from './cacheDictForm'
export default {
    name:'cacheDictList',
    components: {
        LTable,
        cacheDictForm
    },
    props:{

    },
    mixins:[SysMixin],
    data(){
        return{
            systemNo:'',
            cacheDictListSelectedRowKeys:[],
            axiosUrl:'/SysDictController/page',
            formAttributes:[
                {field:'dictName',label:'字典名称',component:'input',condition:'like'},
                {field:'dictCode',label:'字典编号',component:'input',condition:'like'},
               
            ],
            queryForm:[
                {field:'dictName',label:'字典名称',component:'input',val:'',condition:'like'},
                {field:'dictCode',label:'字典编号',component:'input',val:'',condition:'like'},
                {field:'cacheKey',label:'缓存KEY',component:'input',val:'',condition:'like'},
            ],
            initQuery:[{field:'dictType',val:'3'}],
            initOrder:[{field:'dictOrder',val:'asc'}],
            
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                    return parseInt(index)+1;
                    }
                },
                
                {
                    title: '模块',
                    dataIndex: 'systemNo'
                },
                {
                    title: '字典名称',
                    dataIndex: 'dictName'
                    
                },
                {
                    title: '字典编号',
                    dataIndex: 'dictCode', 
                },
                {
                    title: '缓存KEY',
                    dataIndex: 'cacheKey'
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '100px',
                    scopedSlots: { customRender: 'action' }
                }
            ]

        }
    },
    methods:{
         onSelectChange (selectedRowKeys, selectedRows) {
            this.cacheDictListSelectedRowKeys = selectedRowKeys;
            // console.log(selectedRowKeys);
            // console.log(selectedRows);
        },
        queryBySystemNo(systemNo){
          let that = this;
          that.systemNo=systemNo
          that.initQuery=[{field:'dictType',val:'3'},{field:'systemNo',val:systemNo}];
           that.$nextTick(() => {
              that.$refs["cacheDictList"].searchQuery()
            })  
        }
    }
    
}
</script>